<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="frm.ssh.util.page.SearchBean"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
	<head>
		<script language="javascript" src="<%=contextPath%>/js/func.js"type=""></script>
		<script type="text/javascript" src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
	</head>
	<body style="margin: 0;overflow:hidden"> 
	<script type="text/javascript">
		Ext.onReady(function(){
			
			  Ext.QuickTips.init();
			  
			  var xg = Ext.grid;
			  var expand=false; 
			  var statusdata=[['0','未提交'],['1','已提交 ']];
			  var strWindowURL="<%=contextPath%>/jsp/business/plan/selectStation.jsp";
			  
			  var statusSelect=new Ext.form.ComboBox({
				    fieldLabel:'状态',
				    width : 200,
				    store:new Ext.data.SimpleStore({
				     fields:['value','text'],
				     data:statusdata
				    }),
				    emptyText:'请选择',
				    mode:'local',
				    triggerAction:'all',
				    valueFiled:'value',
				    displayField:'text',
				    width : 120,
				    readyOnly:true
			 }); 
				 
			 var selectStationWin = new Ext.Window({
		    		title   : "选择变电站",
		    		width   : 460,
		    		height   : 478,
		    		closable   : true,
		    		modal   : true,
		    		plain   : true,
		    		//maximizable : true,
		    		draggable   : false,
		    		html   : '<iframe  src="' + strWindowURL + '" width="100%" marginwidth="0" height="100%" marginheight="0" scrolling="no" frameborder="0"></iframe>'
		    		});

			  var searchform = new Ext.form.FormPanel({
			     labelAlign : 'right',
			     buttonAlign : 'center',
			     bodyStyle:'background-color:#FFFFFF;border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
			     border:false,
			     width: 855,
			     labelWidth : 60,
			     frame : true,
			     defaults: {
			            anchor: '0'
			     },
			     el:'form',
			     items: [{
				        layout:'column',                  //定义该元素为布局为列布局方式
				        border:false,
				        bodyStyle:'border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
				        labelSeparator:'：',
				        items:[{
				            columnWidth:.5,               //该列占用的宽度，标识为50％
				            layout: 'form',
				            bodyStyle:'border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
				            border:false,
				            items: [{                     //这里可以为多个Item，表现出来是该列的多行
				                width : 200,
				                xtype:'textfield',
				                fieldLabel: '变电站',
				                name: 'searchBean.con2',
				                listeners:{
				                	'focus': function(){
				            			selectStationWin.show();  
				                   } 
	                            } 
				            },{                           //这里可以为多个Item，表现出来是该列的多行
				                width : 200,
				                xtype:'textfield',
				                fieldLabel: '电压等级',
				                name: 'searchBean.con3'
				            }]
				        },{
				            columnWidth:.5,
				            layout: 'form',
				            bodyStyle:'border-color:#FFFFFF;padding:0px;margin:0px;padding-top:0px;',
				            border:false,
				            items: [statusSelect,
						            {	xtype: 'compositefield',
				                		fieldLabel: '日期范围',
				                		msgTarget : 'side',
				                		anchor    : '-20',
				                		defaults: {
				                    		flex: 1
				                		},
				                		items: [{
				                        	xtype: 'datefield',
				                        	name : 'startDate',
					                        format:'Y-m-d'
				                    	},{
				                        	xtype: 'datefield',
				                        	name : 'endDate',
				                        	format:'Y-m-d'
				                    	}]
				            }]
				        }]
				    }],
			     tbar : [{
			    	 pressed : true,
				     text:'填写准备情况',
				     icon:contextpath + '/images/edit.gif',
				     handler:function(){
			    	 	newPlanFormWin.show();
			     	}
				  },'-',{
				    	 pressed : true,
					     text:'起草工作任务',
					     icon:contextpath + '/images/edit.gif',
					     handler:function(){
				    	 	//newPlanFormWin.show();
				     	}
					  },'->',{
					    pressed : true,
				       	text : '查询',
				       	icon:contextpath + '/images/query.gif',
				        handler : function() {
				            if(!expand){ //当查询表展开时，设置查询表单的高和grid的高
				             document.getElementById('form').style.height = "120px";
				             document.getElementById('form').style.overflow = "visible";
				             grid.setHeight(document.body.clientHeight-1);
				             form.setHeight(120);
				             expand=true;
				            }else{    //当查询表收缩时，设置查询表单的高和grid的高
				                document.getElementById('form').style.height = "34px";
				                document.getElementById('form').style.overflow = "hidden";
				                grid.setHeight(document.body.clientHeight);
				                form.setHeight(34);
				                expand=false;
				            }
				      }
				   }],
				   bbar:{width: '100%',
			    	 	items:['->'
			    	            ,{
			    	            	pressed : true,
			    	                xtype: 'tbbutton',
			    	                text: '确定',
			    	                width: 80
			    	            },{
			    	                xtype: 'tbspacer',
			    	                width: 10
			    	            },{
			    	            	pressed : true,
			    	                xtype: 'tbbutton',                
			    	                text: '重置',
			    	                width: 80
			    	            }]  
			     } 
			  });

			  var newPlanForm = new Ext.form.FormPanel({
				  frame:true,
				  autoHeight:true,	
				  width:600,
				  labelWidth:80,
				  items:[{
					  xtype:"fieldset",
					  title:"基本信息",
					  autoHeight:true,			//使自适应展开排版
					  items:[{
						  layout:'column',
				          border:false,
				          items:[{
						  	columnWidth:.5,
						  	layout: 'form',
						    border:false,
						    items: [{
						    	 xtype:'datefield',
				                 fieldLabel: '开始日期',
				                 name: 'startdate',
				                 format:'Y-m-d',
				                 anchor:'95%'
			                   
			                },{
			                   
			                    xtype:'textfield',
					            fieldLabel: '变电站',
					            name: 'stationname',
					            anchor:'95%'
			                },{
			                    xtype:'textfield',
					            fieldLabel: '停电范围',
					            name: 'powerrange',
					            anchor:'95%'
			                }]
				          },{
							  	columnWidth:.5,
							  	layout: 'form',
							    border:false,
							    items: [{
							    	xtype:'datefield',
				                    fieldLabel: '结束日期',
				                    format:'Y-m-d',
				                    name: 'enddate',
				                    anchor:'95%'
				                   
				                }, {
				                    
				                    xtype:'textfield',
						            fieldLabel: '电压等级',
						            name: 'voltagelevel',
						            anchor:'95%'
				                },{
				                    xtype:'textfield',
						            fieldLabel: '设备类别',
						            name: 'etype',
						            anchor:'95%'
				                }]
				          }]
					  },{ 
						  columnWidth:1,
						  xtype:'textfield',
				          fieldLabel: '工作项目',
				          name: 'workcontent',
				          anchor:'97.5%'
					  },{ 
						  columnWidth:1,
						  xtype:'textfield',
				          fieldLabel: '备注',
				          name: 'remarks',
				          anchor:'97.5%'
					  }]
						  	
				  },{
						  xtype:"fieldset",
						  id:'gzzz_fs',
						  title:"工作组织",
						  hidden:true,
						  collapsible: true,
						  collapsed: true,
						  autoHeight:true,			//使自适应展开排版
						  items:[{
							  xtype:"fieldset",
							  title:"变电检修班",
							  autoHeight:true,	
							  items:[{
							         layout:'column',
							         border:false, 
							         items: [{
								  			columnWidth:.5, 
								  			layout: 'form',
								  			items: [{
								  					xtype:'textfield',
									  				fieldLabel:"负责人",
									  				name:"bdfzr",
									  				 anchor:'95%'
								  			}]
							         	  },{
							        		columnWidth:.5, 
											layout: 'form',
											items: [{
												    xtype:'textfield',
											  		fieldLabel:"工作班成员",
											  		name:"bdgzzcy",
											  		anchor:'95%'
										 	}]
							             }]
							     }]
							  },{
								  xtype:"fieldset",
								  title:"变压器班",
								  autoHeight:true,	
								  items:[{
								         layout:'column',
								         border:false, 
								         items: [{
									  			columnWidth:.5, 
									  			layout: 'form',
									  			items: [{
									  					xtype:'textfield',
										  				fieldLabel:"负责人",
										  				name:"bdfzr",
										  				 anchor:'95%'
									  			}]
								         	  },{
								        		columnWidth:.5, 
												layout: 'form',
												items: [{
													    xtype:'textfield',
												  		fieldLabel:"工作班成员",
												  		name:"bdgzzcy",
												  		anchor:'95%'
											 	}]
								             }]
								     }]
								  },{
									  xtype:"fieldset",
									  title:"继电保护班",
									  autoHeight:true,	
									  items:[{
									         layout:'column',
									         border:false, 
									         items: [{
										  			columnWidth:.5, 
										  			layout: 'form',
										  			items: [{
										  					xtype:'textfield',
											  				fieldLabel:"负责人",
											  				name:"bdfzr",
											  				 anchor:'95%'
										  			}]
									         	  },{
									        		columnWidth:.5, 
													layout: 'form',
													items: [{
														    xtype:'textfield',
													  		fieldLabel:"工作班成员",
													  		name:"bdgzzcy",
													  		anchor:'95%'
												 	}]
									             }]
									     }]
									  },{
										  xtype:"fieldset",
										  title:"试验班",
										  autoHeight:true,	
										  items:[{
										         layout:'column',
										         border:false, 
										         items: [{
											  			columnWidth:.5, 
											  			layout: 'form',
											  			items: [{
											  					xtype:'textfield',
												  				fieldLabel:"负责人",
												  				name:"bdfzr",
												  				 anchor:'95%'
											  			}]
										         	  },{
										        		columnWidth:.5, 
														layout: 'form',
														items: [{
															    xtype:'textfield',
														  		fieldLabel:"工作班成员",
														  		name:"bdgzzcy",
														  		anchor:'95%'
													 	}]
										             }]
										     }]
										  }]
						  },{
							  xtype:"fieldset",
							  title:"工作监督及准备情况",
							  id:'gzjd_fs',
							  hidden:true,
							  collapsible: true,
							  collapsed: true,
							  autoHeight:true,	
							  items:[{
							         layout:'column',
							         border:false, 
							         items: [{
								  			columnWidth:.5, 
								  			layout: 'form',
								  			items: [{
								  					xtype:'textfield',
									  				fieldLabel:"到位人员",
									  				name:"bdfzr",
									  				 anchor:'95%'
								  			},{
							  					xtype:'textfield',
								  				fieldLabel:"车辆",
								  				name:"bdfzr",
								  				 anchor:'95%'
							  				},{
							  					xtype:'textfield',
								  				fieldLabel:"同车人员",
								  				name:"bdfzr",
								  				 anchor:'95%'
							  				}]
							         	  },{
							        		columnWidth:.5, 
											layout: 'form',
											items: [{
												    xtype:'textfield',
											  		fieldLabel:"验收人员",
											  		name:"bdgzzcy",
											  		anchor:'95%'
										 	},{
											    xtype:'textfield',
										  		fieldLabel:"外用工",
										  		name:"bdgzzcy",
										  		anchor:'95%'
									 	},{
										    xtype:'textfield',
									  		fieldLabel:"准备情况",
									  		name:"bdgzzcy",
									  		anchor:'95%'
								 	}]
							             }]
							  }]
						  }],
				tbar:{
					 width: '100%',
					 items:[{
						pressed : true,
						text : '保存',
						icon:contextpath + '/images/save.gif',
					    handler:function(){
				    	 	
				     	}
					},'-',{
						pressed : true,
						text : '查看工作组织',
						icon:contextpath + '/images/remark.gif',
					    handler:function(){
						 Ext.getCmp('gzzz_fs').show();
				     	}
					},'-',{
						pressed : true,
						text : '填写工作监督及准备情况',
						icon:contextpath + '/images/remark.gif',
					    handler:function(){
						 Ext.getCmp('gzjd_fs').show();
				     	}
					},'-',{
						pressed : true,
						text : '关闭',
						icon:contextpath + '/images/delete.gif',
					    handler:function(){
				    	 	
				     	}
					}]
			  }
					
			  });
			  var newPlanFormWin = new Ext.Window({
				  	title   : "生产计划",
		    		width:615,
		    		autoHeight:true,	
		    		closable   : true,
		    		modal   : true,
		    		buttonAlign : 'center',
		    		plain   : true,
		    		items:[newPlanForm]
			  });
			  var reader = new Ext.data.ArrayReader({}, [
			       {name: 'company'},
			       {name: 'price', type: 'float'},
			       {name: 'change', type: 'float'},
			       {name: 'pctChange', type: 'float'},
			       {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'},
			       {name: 'industry'},
			       {name: 'desc'}
			     ]);
						
			    Ext.grid.dummyData = [
			        ['3m Co',71.72,0.02,0.03,'9/1 12:00am', 'Manufacturing'],
			        ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am', 'Manufacturing'],
			        ['Altria Group Inc',83.81,0.28,0.34,'9/1 12:00am', 'Manufacturing'],
			        ['American Express Company',52.55,0.01,0.02,'9/1 12:00am', 'Finance'],
			        ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am', 'Services'],
			        ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am', 'Services'],
			        ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am', 'Manufacturing'],
			        ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am', 'Services'],
			        ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am', 'Finance'],
			        ['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'9/1 12:00am', 'Manufacturing'],
			        ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am', 'Manufacturing'],
			        ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am', 'Manufacturing'],
			        ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am', 'Automotive']
			    ];
			    
			 var sm = new xg.CheckboxSelectionModel({
			        listeners: {
			            selectionchange: function(sm) {
			                if (sm.getCount()) {
			                	searchform.removeButton.enable();
			                } else {
			                	searchform.removeButton.disable();
			                }
			            }
			        }
			 });
			    
			 var grid = new xg.GridPanel({
			        id:'gzjh-grid',
			        el : 'grid',
			        layout:'fit',
			        region:'center', 
			        bodyStyle:'width:100%;height:100%',
			        store: new Ext.data.Store({
			            reader: reader,
			            data: xg.dummyData
			        }),
			        cm: new xg.ColumnModel([
			            sm,
			            {id:'company',header: "开始时间", width: 100, sortable: true, dataIndex: 'company'},
			            {header: "结束时间", width: 100, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
			            {header: "变电站",   width: 80, sortable: true, dataIndex: 'change'},
			            {header: "电压等级", width: 100, sortable: true, dataIndex: 'pctChange'},
			            {header: "停电范围", width: 100, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'},
			            {header: "工作项目", width: 200, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'},
			            {header: "准备情况",     width: 100, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
			        ]),
			        sm: sm,
			        tbar:[searchform],     //加到grid的工具栏上
			        bbar: new Ext.PagingToolbar({
			        	//pageSize : limit,
			            //store : store,
			            //displayInfo : true,
			            displayMsg : '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
			            emptyMsg : "没有记录"
			        }),
			       
			        //frame:true,
			        //split:true,
			        title:'隔日工作安排',
			        icon:contextpath + '/images/grid.png'
			    });		    

			 document.getElementById('form').style.height = "34px";
			 document.getElementById('form').style.overflow = "hidden";
			 grid.setHeight(document.body.clientHeight);
			 grid.render();

		});
		</script>
		<div id="form" style="width:100%;height:35;font-size:0;"></div>
		<div id="grid" style="width:100%;height:100%;"></div>		
        </div> 
	</body>
</html>

